import React, { Component } from 'react';
import { Router, Route, IndexRoute } from 'react-router';
import App from 'common/containers/app.js';
import Error from 'common/containers/error.js';

import BookClassifyList from '../containers/bookClassifyList/bookClassifyList.js';
import Search from 'common/components/search.js';
import Comment from '../containers/comment/comment.js';
import BookDetail from '../containers/bookDetail/bookDetail.js';
import BookRead from '../containers/bookRead/bookRead.js';

import Home from './home/home.js';
import Friend from './friend/friend.js';
import BookShelf from './bookShelf/bookShelf.js';
import User from './user/user.js';

import BookClassify from '../containers/bookClassify/bookClassify.js';
import BookSort from '../containers/bookSort/bookSort.js';
import BookActivity from '../containers/bookActivity/bookActivity.js';
import BookFree from '../containers/bookFree/bookFree.js';

import UserInfo from '../containers/userInfo/userInfo.js';
import UserCash from '../containers/userCash/userCash.js';
import UserOrder from '../containers/userOrder/userOrder.js';
import UserNotify from '../containers/userNotify/userNotify.js';

import 'common/containers/app.less';

/**
 * 路由
 */
class RouteMap extends Component{

	onUpdate = () => {
		window.scrollTo(0,0);
	}

	render(){
		return(
			<Router history={this.props.history} onUpdate={this.onUpdate}>
				<Route path="/" component={App}>
					<IndexRoute component={Home} title="主页" showTop={false} showBackHome={false} showBottom={true} selectMenuIndex={0}/>
					<Route path="/friend" component={Friend} title="书友" showTop={false} showBackHome={false} showBottom={true} selectMenuIndex={1}/>
					<Route path="/bookShelf" component={BookShelf} title="书架" showTop={false} showBackHome={false} showBottom={true} selectMenuIndex={2}/>
					<Route path="/user" component={User} title="我的" showTop={false} showBackHome={false} showBottom={true} selectMenuIndex={3}/>
					
					<Route path="/bookClassifyList/:classifyName/:classifyKey" component={BookClassifyList} title="图书分类列表" showBackHome={false} showTop={false}/>
					<Route path="/search" component={Search} title="搜索图书" showBackHome={false}/>
					<Route path="/comment" component={Comment} title="评论详情" showBackHome={false}/>
					<Route path="/bookDetail/:id" component={BookDetail} title="图书详情" showTop={false}/>
					<Route path="/bookRead/:id" component={BookRead} title="图书内容" showTop={false} showBackHome={false}/>
					
					<Route path="/bookClassify" component={BookClassify} title="图书分类" showBackHome={false}/>
					<Route path="/bookSort" component={BookSort} title="排行榜" showBackHome={false}/>
					<Route path="/bookActivity" component={BookActivity} title="活动图书" showBackHome={false}/>
					<Route path="/bookFree" component={BookFree} title="免费图书" showBackHome={false}/>
					
					<Route path="/userInfo" component={UserInfo} title="我的信息" showBackHome={false}/>
					<Route path="/userCash" component={UserCash} title="我的书币" showBackHome={false}/>
					<Route path="/userOrder" component={UserOrder} title="我的订单" showBackHome={false}/>
					<Route path="/userNotify" component={UserNotify} title="我的消息" showBackHome={false}/>

					<Route path="*" component={Error}/>
				</Route>
			</Router>
		)
	}
}

export default RouteMap;